package cn.sofwin.day0122.homework.Hero;

public class Hero {
    public static double maxEXP = 30 * (Math.pow(30, 3) + 5 * 30) - 80;
    private int N;
    private double EXP;

    public Hero() {
        this.EXP = 0;
    }

    public Hero(double EXP) {
        if (EXP < 0 || EXP > maxEXP){
            System.out.println("经验值不合法");
        }else {
            // 当前等级=（输入的经验值<=对应等级的最大经验值时）
            int N = 1;
            while (EXP > (30 * (Math.pow(N, 3) + 5 * N)) - 80) {
                N++;
            }
            this.N = N;
            this.EXP = EXP;
        }
    }

    public void showInfo(){
        System.out.println("等级为" + this.N + "，经验值为" + this.EXP);
    }
}
